/*
 * Air Roommates Accounts
 *Copyright 2009 - Julien EVANO & Enguerran GILLET
 *
 *This program is free software: you can redistribute it and/or modify
 *it under the terms of the GNU General Public License as published by
 *the Free Software Foundation, either version 3 of the License, or
 *(at your option) any later version.
 *
 *This program is distributed in the hope that it will be useful,
 *but WITHOUT ANY WARRANTY; without even the implied warranty of
 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *GNU General Public License for more details.
 *
 *You should have received a copy of the GNU General Public License
 *along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *Distributed under the terms of the GNU GPL v3.
 *http://www.gnu.org/licenses/gpl-3.0.html
 */

/*
 * **************
 * Tables Records
 * **************
 * All tables are described below in order to insert/update/delete in each of them
 */
air.trace('ARA.data.record.table');
Ext.namespace('ARA.data.record.table');
/**
 * Group Record
 * @table GROUPS
 * @description groups of profils
 * @relation * 1 to n PROFILS-GROUPS, * 1 to n ENTRIES
 * @field groupId primary key
 */
ARA.data.record.table.Group = Ext.data.Record.create([
    {name: 'groupId', type:'string'},
    {name: 'groupName', type:'string'}
]);

/**
 * Profil Record
 * @table PROFILS
 * @description profils, ie roommates
 * @relation * 1 to n PROFILS-GROUPS, * 1 to n ENTRIES
 * @field profilId primary key
 * @field firstName
 * @field lastName
 * @field email
 * @field mobile
 */
ARA.data.record.table.Profil = Ext.data.Record.create([
	{name: 'profilId', type:'string'},
	{name: 'firstName', type:'string'},
	{name: 'lastName', type:'string'},
	{name: 'email', type:'string'},
	{name: 'mobile', type:'string'}
]);

/**
 * ProfilGroup Record
 * @table PROFILS-GROUPS
 * @description relation between profils and groups
 * @relation * n to 1 PROFILS, * n to 1 GROUPS
 * @field profilGroupId primary key
 * @field profilId foreign key
 * @field groupId foreign key
 */
ARA.data.record.table.ProfilGroup = Ext.data.Record.create([
	{name: 'profilGroupId', type:'string'},
 	{name: 'profilId', type:'string'},
 	{name: 'groupId', type:'string'}
]);

/**
 * Entry Record
 * @table ENTRIES
 * @description credits and debits for each profils in their groups
 * @relation * n to 1 PROFILS, * n to 1 GROUPS, * n to 1 CATEGORY, * n to 1 UNDERCATEGORY, * n to 1 CURRENCY
 * @field entryId primary key
 * @field profilId
 * @field groupId
 * @field amount
 * @field date
 * @field type (debit or credit or donation)
 * @field description
 * @field categoryId
 * @field underCategoryId
 * @field currencyId several currencies can be possible in each groups
 */
ARA.data.record.table.Entry = Ext.data.Record.create([
	{name: 'entryId', type:'int'},
	{name: 'profilId', type:'string'},
	{name: 'groupId', type:'string'},
	{name: 'amount', type:'float'},
	{name: 'date', type:'date', dateFormat: Ext.sql.Proxy.DATE_FORMAT},
	{name: 'type', type:'string'},
	{name: 'description', type:'string'},
	{name: 'categoryId', type:'string'},
	{name: 'underCategoryId', type:'string'},
	{name: 'currencyId', type:'string'}
]);

/**
 * Category Record
 * @table CATEGORY
 * @description category to describe the debit or credit entry
 * @relation * 1 to n CATEGORIES-UNDERCATEGORIES, * 1 to n ENTRIES
 * @field categoryId primary key
 */
ARA.data.record.table.Category = Ext.data.Record.create([
	{name: 'categoryId', type:'string'}
]);

/**
 * UnderCategory Record
 * @table UNDERCATEGORY
 * @description under-category in relation with the category to describe the debit or credit entry
 * @relation * 1 to n CATEGORIES-UNDERCATEGORIES, * 1 to n ENTRIES
 * @field underCategoryId primary key
 */
ARA.data.record.table.UnderCategory = Ext.data.Record.create([
 	{name: 'underCategoryId', type:'string'}
 ]);

/**
 * CategoryUnderCategory Record
 * @table CATEGORIES-UNDERCATEGORIES
 * @description relation between under-categories and categories
 * @relation * n to 1 CATEGORY, * n to 1 UNDERCATEGORY
 * @field catUnderCatId primary key
 * @field categoryId foreign key
 * @field underCategoryId foreign key
 */
ARA.data.record.table.CategoryUnderCategory = Ext.data.Record.create([
	{name: 'catUnderCatId', type:'string'},
  	{name: 'categoryId', type:'string'},
  	{name: 'underCategoryId', type:'string'}
]);

/**
 * Currency Record
 * @table CURRENCY
 * @description currencies available for the application
 * @relation * 1 to n ENTRIES
 * @field currencyId primary key
 * @field currencySymbol
 */
ARA.data.record.table.Currency = Ext.data.Record.create([
	{name: 'currencyId', type:'string'},
	{name: 'currencySymbol', type:'string'}
]);

